Test Setup Failed
Push — master ( cd1dab...2a689d )
by
unknown
03:51
created

payment-delete-action.js ➔ define   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 61

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 5
dl 0
loc 61
rs 9.5147
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A payment-delete-action.js ➔ ... ➔ DeleteAction.extend.getConfirmDialog 0 14 2
A payment-delete-action.js ➔ ... ➔ DeleteAction.extend.initialize 0 7 2
A payment-delete-action.js ➔ ... ➔ PaymentDeleteAction 0 3 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
define([
2
    'underscore',
3
    'oroui/js/messenger',
4
    'orotranslation/js/translator',
5
    'oroui/js/delete-confirmation',
6
    'oro/datagrid/action/delete-action'
7
], function(_, messenger, __, DeleteConfirmation, DeleteAction) {
8
    'use strict';
9
10
    var PaymentDeleteAction;
11
12
    /**
13
     * Delete action with confirm dialog, triggers REST DELETE request
14
     *
15
     * @export  oro/datagrid/action/payment_delete-action
16
     * @class   oro.datagrid.action.PaymentDeleteAction
17
     * @extends oro.datagrid.action.DeleteAction
18
     */
19
    PaymentDeleteAction = DeleteAction.extend({
20
21
        /** @property {Function} */
22
        confirmModalConstructor: DeleteConfirmation,
23
24
        /** @property {String} */
25
        confirm_content: __('Are you sure you want to delete this item?'),
26
27
        /**
28
         * @inheritDoc
29
         */
30
        constructor: function PaymentDeleteAction() {
31
            PaymentDeleteAction.__super__.constructor.apply(this, arguments);
32
        },
33
34
        /**
35
         * @inheritDoc
36
         */
37
        initialize: function(options) {
0 ignored issues
show
Unused Code introduced by
The parameter options is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
38
            if (this.model.has('payment_delete_message')) {
39
                this.confirm_content = this.model.get('payment_delete_message');
40
            }
41
42
            DeleteAction.__super__.initialize.apply(this, arguments);
43
        },
44
45
        /**
46
         * Get view for confirm modal
47
         *
48
         * @return {oroui.Modal}
49
         */
50
        getConfirmDialog: function(callback) {
51
            if (!this.confirmModal) {
52
                this.confirmModal = (new this.confirmModalConstructor({
53
                    title: __(this.messages.confirm_title),
54
                    content: this.confirm_content,
55
                    okText: __(this.messages.confirm_ok),
56
                    cancelText: __(this.messages.confirm_cancel)
57
                }));
58
                this.listenTo(this.confirmModal, 'ok', callback);
59
60
                this.subviews.push(this.confirmModal);
61
            }
62
            return this.confirmModal;
63
        }
64
    });
65
66
    return PaymentDeleteAction;
67
});
68